package lt.marsrutai.mobile.android.util;

import java.util.List;

import lt.marsrutai.mobile.android.model.ArrivalTime;
import lt.marsrutai.mobile.android.model.enums.DateTime;

public class TimeUntilNextDeparture {

    private String returnString = "??";

    public TimeUntilNextDeparture(List<ArrivalTime> trackStopTimes) {
        final int AFTER = 1;

        DateTime now = new DateTime();

        for (ArrivalTime stopTime: trackStopTimes) {
            if (CalendarHourMinuteComparator.INSTANCE.compare(stopTime.getScheduledTime(), now.getCalendar()) == AFTER) {
                returnString = now.minutesUntil(stopTime.getScheduledTime()) + " m";
                return;
            }
        }
    }

    @Override
    public String toString() {
        return returnString;
    }

}
